/*
 * @lc app=leetcode.cn id=7 lang=javascript
 *
 * [7] 整数反转
 */

// @lc code=start
/**
 * @param {number} x
 * @return {number}
 */
var reverse = function (x) {
    let old = Math.abs(x)
    let res = 0
    while (old > 0) {
        res = res * 10 + old % 10
        old = Math.floor(old / 10)
    }
    res = x < 0 ? -res : res
    if (-Math.pow(2, 31) <= res && res <= Math.pow(2, 31)) { return res } else {
        return 0
    }
};
// @lc code=end
a = reverse(-1200)
console.log(a)
